<template>
	<div>
        <el-upload
                :data="paramData"
                class="upload-demo"
                ref="upload"
                action="http://192.168.0.214:8784/m_manage/file/upload"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                :file-list="fileList"
                :limit="1"
                :on-exceed="handleExceed"
                :auto-upload="false"
                :on-success="uploadSuccess">
            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
        </el-upload>

	</div>
</template>

<script>


	import { getUserList,addUser,editUser,deleteUser } from '../api/api';

	export default {
		data() {
			return {
                fileList: [],
                paramData:{sys:1,module:1,keyId:"12312312312"},// todo 文件上传附加参数，必须先定义，55555555而且44455后续修改必须用：属性引用修改：this.paramData.keyId="9999999999999999999999";
			}
		},
		methods: {
            submitUpload() {
                this.paramData.keyId="9999999999999999999999";
                this.$refs.upload.submit();
            },
            handleRemove(file, fileList) {
                console.log("移除文件");
                console.log(file, fileList);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }？`);
            },
            handlePreview(file) {
                console.log("点击文件");
                console.log(file);
            },
            handleExceed(files, fileList) {
                this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }？`);
            },
            uploadSuccess(response, file, fileList){
                console.log(response.data.fileUri)
            },
		},
		mounted() {
		}
	}

</script>